package com.shwread.android.ui.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.shwread.android.qysw10000182.R;

/**
 * 项目名称：association
 * 包名称：com.shwread.android.ui.dialog
 * 类描述：
 * 创建人： wayne
 * 创建时间 2016/2/2 17:36.
 */
public class AttendOutDialog
        extends
        Dialog
{

    protected TextView tvText,tvText1,tvText2,tvText3;

    private Context    context;
    protected TextView vTitle;
    private SimpleOutListener listener;

    public AttendOutDialog(Context context) {
        super(context, R.style.common_dialog);

        this.context = context;

        setCanceledOnTouchOutside(true);

        findViews();
        setListeners();
    }
    public AttendOutDialog(Context context,SimpleOutListener listener) {
        super(context, R.style.common_dialog);

        this.context = context;
        this.listener = listener;
        setCanceledOnTouchOutside(true);

        findViews();
        setListeners();
    }
    private void findViews() {
        View view = LayoutInflater.from(context).inflate(R.layout.attend_out_dialog, null);

        tvText = (TextView) view.findViewById(R.id.common_dialog_text);
        tvText1 = (TextView) view.findViewById(R.id.common_dialog_text1);
        tvText2 = (TextView) view.findViewById(R.id.common_dialog_text2);
        tvText3 = (TextView) view.findViewById(R.id.common_dialog_text3);
        vTitle = (TextView) view.findViewById(R.id.common_dialog_title);

        setContentView(view);
    }

    private void setListeners() {
        ClickListener l = new ClickListener();

        tvText1.setOnClickListener(l);
        tvText2.setOnClickListener(l);
        tvText3.setOnClickListener(l);
    }

    protected void clickOk(View v) {
        dismiss();
    }

    protected void clickCancel(View v) {
        dismiss();
    }

    private class ClickListener
            implements
            View.OnClickListener
    {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.common_dialog_text1:
                    if(listener != null)
                    {
                        listener.out();
                    }
                    clickOk(v);
                    break;
                case R.id.common_dialog_text2:
                    if(listener != null)
                    {
                        listener.leave();
                    }
                    clickOk(v);
                    break;
                case R.id.common_dialog_text3:
                    if(listener != null)
                    {
                        listener.other();
                    }
                    clickOk(v);
                    break;
            }
        }

    }

    public interface SimpleOutListener
    {
        void out();

        void leave();

        void other();
    }

}
